// 标签页选中事件
function pageRecycleBinOnSelect(title, index) {
    switch (index) {
        case 0:
            if ($('#page_recycle_doc_grid').data('kendoGrid') == undefined)
                initPageRecycleDocGrid();
            else
                $('#page_recycle_doc_grid').data('kendoGrid').dataSource.read();
            break;
        default:
            if ($('#page_recycle_emp_grid').data('kendoGrid') == undefined)
                initPageRecycleEmpGrid();
            else
                $('#page_recycle_emp_grid').data('kendoGrid').dataSource.read();
            break;
    }
}

/**
 * 获取选中数组
 * @param ele
 * @returns {null|*}
 */
const getSelectItems = function (ele) {
    let k = ele.data('kendoGrid');
    if (k == undefined) return null;
    let selections = k.select();
    if (!selections) return null;
    let items = [];
    for (let i = 0; i < selections.length; i++) {
        items.push(k.dataItem(selections[i]));
    }
    return items;
}

// 初始化
function initPageRecycleDocGrid() {
    let menuId = 4;
    let SUFFIX = '_DOC';
    let doc_number = new kendo.data.DataSource([]);
    let doc_no = new kendo.data.DataSource([]);
    let doc_type_name = new kendo.data.DataSource([]);
    let id = new kendo.data.DataSource([]);
    let doc_name = new kendo.data.DataSource([]);
    let save_location = new kendo.data.DataSource([]);
    let person_name = new kendo.data.DataSource([]);
    let user_name = new kendo.data.DataSource([]);
    let remarks = new kendo.data.DataSource([]);
    let other_01 = new kendo.data.DataSource([]);
    let other_02 = new kendo.data.DataSource([]);
    let other_03 = new kendo.data.DataSource([]);
    let document_describe = new kendo.data.DataSource([]);
    let dataSource = new kendo.data.DataSource({
        transport: {
            read: {
                url: "document/report",
                dataType: "json",
                type: "GET",
                data: {
                    status: 0
                }
            }
        },
        schema: {
            model: {
                fields: {
                    doc_date: {type: 'date'},
                    create_time: {type: "date"},
                    extra_file_count: {type: 'number'},
                }
            }
        },
        aggregate: [
            {field: "extra_file_count", aggregate: "sum"},
        ],
        pageSize: 500,
        change: function (e) {
            //获取过滤条件
            let filtrer = this.filter();
            //获取所有数据
            let allData = this.data();
            //进行过滤条件的筛选
            let query = new kendo.data.Query(allData);
            //获取过过滤后的数据
            let data = query.filter(filtrer).data;
            doc_number.data(unique(data, 'doc_number'));
            doc_no.data(unique(data, 'doc_no'));
            doc_type_name.data(unique(data, 'doc_type_name'));
            id.data(unique(data, 'id'));
            doc_name.data(unique(data, 'doc_name'));
            save_location.data(unique(data, 'save_location'));
            person_name.data(unique(data, 'person_name'));
            user_name.data(unique(data, 'user_name'));
            remarks.data(unique(data, 'remarks'));
            other_01.data(unique(data, 'other_01'));
            other_02.data(unique(data, 'other_02'));
            other_03.data(unique(data, 'other_03'));
        },
        requestStart: function (e) {
            $('.easyui-linkbutton').each(function (index, item) {
                let btn = $(item);
                if (btn.linkbutton('options').text == '查询' || (btn.linkbutton('options').text == '过滤')) {
                    btn.linkbutton('disable')
                }
            })
        },
        requestEnd: function (e) {
            let response = e.response;
            if (response && response['message']) {
                $.messager.show({title: '提示', msg: response['message']})
            }
            $('.easyui-linkbutton').each(function (index, item) {
                let btn = $(item);
                if (btn.linkbutton('options').text == '查询' || (btn.linkbutton('options').text == '过滤')) {
                    btn.linkbutton('enable')
                }
            })
        }
    });

    let columns = [
        {field: '', title: "序号", template: "<span class='row-number'></span>", width: 50},
        {
            field: 'doc_number',
            title: '档案编号',
            width: 98,
            footerTemplate: '总计:',
            filterable: {multi: true, search: true, checkAll: true, dataSource: doc_number},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'},
            footerAttributes: {style: 'color: red;text-align:center;'}
        },
        {
            field: 'doc_no',
            title: '档案登记号',
            width: 98,
            filterable: {multi: true, search: true, checkAll: true, dataSource: doc_no},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'},
            footerAttributes: {style: 'color: red;text-align:center;'}
        },
        {
            field: 'doc_date',
            title: '档案日期',
            width: 98,
            format: "{0: yyyy-MM-dd}",
            headerAttributes: {style: 'text-align:center;'},
            attributes: {class: 'kendo-custum-char'}
        },
        {
            field: 'doc_type_name',
            title: '档案类型',
            width: 110,
            filterable: {multi: true, search: true, checkAll: true, dataSource: doc_type_name},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'}
        },
        {
            field: 'id',
            title: '编号',
            width: 110,
            filterable: {multi: true, search: true, checkAll: true, dataSource: id},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'}
        },
        {
            field: 'doc_name',
            title: '档案名',
            width: 70,
            filterable: {multi: true, search: true, checkAll: true, dataSource: doc_name},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'}
        },
        {
            field: "save_location",
            title: '档案存放区域',
            width: 92,
            filterable: {multi: true, search: true, checkAll: true, dataSource: save_location},
            attributes: {style: "text-align:right;white-space:nowrap;text-overflow:ellipsis;"},
            footerAttributes: {style: "text-align:right;"},
            headerAttributes: {style: 'text-align:center;'}
        },
        {
            field: 'person_name',
            title: '负责人',
            width: 92,
            format: "{0:n1}",
            filterable: {multi: true, search: true, dataSource: person_name},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'}
        },
        {
            field: 'user_name',
            title: '创建人',
            width: 88,
            filterable: {multi: true, search: true, checkAll: true, dataSource: user_name},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'}
        },
        {
            field: 'remarks',
            title: '备注',
            width: 98,
            filterable: {multi: true, search: true, checkAll: true, dataSource: remarks},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'}
        },
        {
            field: 'document_describe',
            title: '档案说明',
            width: 80,
            filterable: {multi: true, search: true, checkAll: true, dataSource: document_describe},
            footerAttributes: {style: "text-align:right;"},
            attributes: {style: "text-align:right;white-space:nowrap;text-overflow:ellipsis;"},
            headerAttributes: {style: 'text-align:center;'}
        },
        {
            field: "other_01",
            title: '其他1',
            width: 80,
            filterable: {multi: true, search: true, checkAll: true, dataSource: other_01},
            attributes: {style: "text-align:right;white-space:nowrap;text-overflow:ellipsis;"},
            footerAttributes: {style: "text-align:right;"},
            headerAttributes: {style: 'text-align:center;'}
        }, {
            field: "other_02",
            title: '其他2',
            width: 80,
            filterable: {multi: true, search: true, checkAll: true, dataSource: other_02},
            attributes: {style: "text-align:right;white-space:nowrap;text-overflow:ellipsis;"},
            footerAttributes: {style: "text-align:right;"},
            headerAttributes: {style: 'text-align:center;'}
        }, {
            field: "other_03",
            title: '其他3',
            width: 80,
            filterable: {multi: true, search: true, checkAll: true, dataSource: other_03},
            attributes: {style: "text-align:right;white-space:nowrap;text-overflow:ellipsis;"},
            footerAttributes: {style: "text-align:right;"},
            headerAttributes: {style: 'text-align:center;'}
        },
        {
            field: 'extra_file_count',
            width: 110,
            title: '附件数量',
            template: function (item) {
                return item.extra_file_count ? parseFloat(item.extra_file_count).toFixed(0) : ''
            },
            footerTemplate: '#=kendo.format("{0:n0}",sum)#',
            format: "{0:n1}",
            attributes: {'class': 'kendo-custum-number'},
            headerAttributes: {style: 'text-align:center;'},
            footerAttributes: {style: "text-align:right;"}
        },
    ];
    let grid = $("#page_recycle_doc_grid").kendoGrid({
        sortable: true,
        resizable: true,
        allowCopy: true,
        selectable: "multiple row",
        editable: false,
        filterable: true,
        title: "报表",
        pageable: {
            pageSize: 200
        },
        dataSource: dataSource,
        excel: {
            fileName: "文件档案.xlsx",
            proxyURL: "",
            allPages: true,
            filterable: true
        },
        columnMenu: {
            sortable: true
        },
        height: '99%',
        reorderable: true,
        dataBound: function () {
            let rows = this.items();
            $(rows).each(function () {
                let index = $(this).index() + 1;
                let rowLabel = $(this).find(".row-number");
                $(rowLabel).html(index);
            });
        },
        columnResize: function (e) {
            let field = e.column.field;
            let newWidth = e.newWidth;
            let oldWidth = e.oldWidth;
            if (newWidth < 20) {
                $(this).hideColumn(field);
            } else {
                $.post("userDeploy/update/single", {
                    menuId: menuId,
                    field: field + SUFFIX,
                    width: newWidth
                }, function (data) {
                    if (data.success) {
                    }
                }, "json");
            }
        },
        columnHide: function (e) {  //列隐藏事件
            let field = e.column.field;
            $.post("userDeploy/update/single", {menuId: menuId, field: field + SUFFIX, hidden: true}, function (data) {
            }, "json");
        },
        columnShow: function (e) {  //列显示事件
            let field = e.column.field;
            $.post("userDeploy/update/single", {menuId: menuId, field: field + SUFFIX, hidden: false}, function (data) {
            }, "json");
        },
        columnReorder: function (e) {
            let newColumns = JSON.parse(JSON.stringify(e.sender.columns))
            newColumns = reorder(newColumns, e.oldIndex, e.newIndex)
            let col = []
            for (let i = 0; i < newColumns.length; i++) {
                if (newColumns[i]['field'])
                    col.push({
                        serialNo: i,
                        menuId: menuId,
                        field: newColumns[i]['field'] + SUFFIX
                    });
            }
            $.ajax({
                url: 'userDeploy/update/batch',
                contentType: 'application/json',
                data: JSON.stringify(col),
                type: 'post',
                dataType: 'json',
                success: function (data) {
                }
            })
        },
    });
    //  绑定双击事件
    grid.on('dblclick', 'tr', function (e) {
        /* let kGrid = $('#page_recycle_doc_grid').data('kendoGrid');
         let selectItem = kGrid.dataItem(e.currentTarget);
         if (selectItem) {
             $('#page_doc_editable_dialog').dialog('open');
             $.ajax({
                 url: 'document/queryByPk/' + selectItem.id,
                 type: 'GET',
                 dataType: 'json',
                 success: function (data) {
                     if (data) {
                         $('#page_doc_editor_form').form('load', data);
                         $.disableFormElement($('#page_doc_editor_form'));
                         $('#page_doc_editor_file_grid').edatagrid('disableEditing');
                         $('#page_doc_editor_file_grid').datagrid('loadData', {
                             total: data.detail.length,
                             rows: data.detail
                         });
                     }
                 }
             })
         }*/
    })
    let k = $('#page_recycle_doc_grid').data('kendoGrid');
    let columnNames = [];
    columns.forEach(item => {
        let arr = {};
        if (item['field']) {
            arr.field = item['field'] + SUFFIX;
            arr.hidden = item['hidden'] ? true : false;
            arr.width = item['width'] ? item['width'] : null;
            arr.menuId = menuId;
            columnNames.push(arr);
        }
    })
    loadOptions(k, columnNames, columns, SUFFIX);
}

function initPageRecycleEmpGrid() {
    let menuId = 4;
    let SUFFIX = '_EMP';
    let id = new kendo.data.DataSource([]);
    let emp_name = new kendo.data.DataSource([]);
    let emp_serial_no = new kendo.data.DataSource([]);
    let emp_number = new kendo.data.DataSource([]);
    let department_name = new kendo.data.DataSource([]);
    let emp_sex = new kendo.data.DataSource([]);
    let duty = new kendo.data.DataSource([]);
    let identity_card = new kendo.data.DataSource([]);
    let birth_place = new kendo.data.DataSource([]);
    let marry_state = new kendo.data.DataSource([]);
    let nation = new kendo.data.DataSource([]);
    let telephone_no_01 = new kendo.data.DataSource([]);
    let telephone_no_02 = new kendo.data.DataSource([]);
    let endowment_insurance = new kendo.data.DataSource([]);
    let housing_provident_fund = new kendo.data.DataSource([]);
    let identity_card_address = new kendo.data.DataSource([]);
    let current_address = new kendo.data.DataSource([]);
    let other_01 = new kendo.data.DataSource([]);
    let other_02 = new kendo.data.DataSource([]);
    let other_03 = new kendo.data.DataSource([]);
    let dataSource = new kendo.data.DataSource({
        transport: {
            read: {
                url: "employee/report",
                dataType: "json",
                type: "GET",
                data: {
                    status: 0
                }
            }
        },
        schema: {
            model: {
                fields: {
                    entry_date: {type: 'date'},
                    leave_date: {type: 'date'},
                    create_time: {type: "date"},
                    extra_file_count: {type: 'number'},
                }
            }
        },
        aggregate: [
            {field: "extra_file_count", aggregate: "sum"},
        ],
        pageSize: 500,
        change: function (e) {
            //获取过滤条件
            let filtrer = this.filter();
            //获取所有数据
            let allData = this.data();
            //进行过滤条件的筛选
            let query = new kendo.data.Query(allData);
            //获取过过滤后的数据
            let data = query.filter(filtrer).data;
            id.data(unique(data, 'id'));
            emp_name.data(unique(data, 'emp_name'));
            emp_serial_no.data(unique(data, 'emp_serial_no'));
            emp_number.data(unique(data, 'emp_number'));
            department_name.data(unique(data, 'department_name'));
            emp_sex.data(unique(data, 'emp_sex'));
            duty.data(unique(data, 'duty'));
            identity_card.data(unique(data, 'identity_card'));
            birth_place.data(unique(data, 'birth_place'));
            marry_state.data(unique(data, 'marry_state'));
            nation.data(unique(data, 'nation'));
            telephone_no_01.data(unique(data, 'telephone_no_01'));
            telephone_no_02.data(unique(data, 'telephone_no_02'));
            endowment_insurance.data(unique(data, 'endowment_insurance'));
            housing_provident_fund.data(unique(data, 'housing_provident_fund'));
            identity_card_address.data(unique(data, 'identity_card_address'));
            current_address.data(unique(data, 'current_address'));
            other_01.data(unique(data, 'other_01'));
            other_02.data(unique(data, 'other_02'));
            other_03.data(unique(data, 'other_03'));
        },
        requestStart: function (e) {
            $('.easyui-linkbutton').each(function (index, item) {
                let btn = $(item);
                if (btn.linkbutton('options').text == '查询' || (btn.linkbutton('options').text == '过滤')) {
                    btn.linkbutton('disable')
                }
            })
        },
        requestEnd: function (e) {
            let response = e.response;
            if (response && response['message']) {
                $.messager.show({title: '提示', msg: response['message']})
            }
            $('.easyui-linkbutton').each(function (index, item) {
                let btn = $(item);
                if (btn.linkbutton('options').text == '查询' || (btn.linkbutton('options').text == '过滤')) {
                    btn.linkbutton('enable')
                }
            })
        }
    })

    let columns = [
        {field: '', title: "序号", template: "<span class='row-number'></span>", width: 50},
        {
            field: 'id',
            title: '编号',
            width: 98,
            footerTemplate: '总计:',
            filterable: {multi: true, search: true, checkAll: true, dataSource: id},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'},
            footerAttributes: {style: 'color: red;text-align:center;'}
        },
        {
            field: 'emp_name',
            title: '姓名',
            width: 98,
            filterable: {multi: true, search: true, checkAll: true, dataSource: emp_name},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'},
            footerAttributes: {style: 'color: red;text-align:center;'}
        },
        {
            field: 'emp_serial_no',
            title: '文档系统编号',
            width: 98,
            filterable: {multi: true, search: true, checkAll: true, dataSource: emp_serial_no},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'},
            footerAttributes: {style: 'color: red;text-align:center;'}
        },
        {
            field: 'emp_number',
            title: '工号',
            width: 98,
            filterable: {multi: true, search: true, checkAll: true, dataSource: emp_number},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'},
            footerAttributes: {style: 'color: red;text-align:center;'}
        },
        {
            field: 'department_name',
            title: '部门名',
            width: 98,
            filterable: {multi: true, search: true, checkAll: true, dataSource: department_name},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'},
            footerAttributes: {style: 'color: red;text-align:center;'}
        },
        {
            field: 'emp_sex',
            title: '性别',
            width: 98,
            filterable: {multi: true, search: true, checkAll: true, dataSource: emp_sex},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'},
            footerAttributes: {style: 'color: red;text-align:center;'}
        },
        {
            field: 'duty',
            title: '职务',
            width: 98,
            filterable: {multi: true, search: true, checkAll: true, dataSource: duty},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'},
            footerAttributes: {style: 'color: red;text-align:center;'}
        },
        {
            field: 'entry_date',
            title: '入职日期',
            width: 98,
            format: "{0: yyyy-MM-dd}",
            headerAttributes: {style: 'text-align:center;'},
            attributes: {class: 'kendo-custum-char'}
        },
        {
            field: 'create_time',
            title: '建档日期',
            width: 98,
            format: "{0: yyyy-MM-dd HH:mm:ss}",
            headerAttributes: {style: 'text-align:center;'},
            attributes: {class: 'kendo-custum-char'}
        },
        {
            field: 'leave_date',
            title: '离职日期',
            width: 98,
            format: "{0: yyyy-MM-dd}",
            headerAttributes: {style: 'text-align:center;'},
            attributes: {class: 'kendo-custum-char'}
        },
        {
            field: 'telephone_no_01',
            title: '电话号码01',
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'},
            filterable: {multi: true, search: true, checkAll: true, dataSource: telephone_no_01},
        },
        {
            field: 'telephone_no_02',
            title: '电话号码02',
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'},
            filterable: {multi: true, search: true, checkAll: true, dataSource: telephone_no_02},
        },
        {
            field: 'endowment_insurance',
            title: '养老保险号码',
            width: 110,
            filterable: {multi: true, search: true, checkAll: true, dataSource: endowment_insurance},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'}
        },
        {
            field: 'housing_provident_fund',
            title: '公积金号码',
            width: 70,
            filterable: {multi: true, search: true, checkAll: true, dataSource: housing_provident_fund},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'}
        },
        {
            field: "identity_card_address",
            title: '身份证号码',
            width: 92,
            filterable: {multi: true, search: true, checkAll: true, dataSource: identity_card_address},
            attributes: {style: "text-align:right;white-space:nowrap;text-overflow:ellipsis;"},
            footerAttributes: {style: "text-align:right;"},
            headerAttributes: {style: 'text-align:center;'}
        },
        {
            field: 'current_address',
            title: '现住址',
            width: 92,
            filterable: {multi: true, search: true, checkAll: true, dataSource: current_address},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'}
        },
        {
            field: 'nation',
            title: '民族',
            width: 92,
            filterable: {multi: true, search: true, checkAll: true, dataSource: nation},
            format: "{0:n1}",
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'}
        },
        {
            field: 'other_01',
            title: '其他1',
            width: 92,
            filterable: {multi: true, search: true, checkAll: true, dataSource: other_01},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'}
        },
        {
            field: 'other_02',
            title: '其他2',
            width: 92,
            filterable: {multi: true, search: true, checkAll: true, dataSource: other_02},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'}
        },
        {
            field: 'other_03',
            title: '其他3',
            width: 92,
            filterable: {multi: true, search: true, checkAll: true, dataSource: other_03},
            attributes: {class: 'kendo-custum-char'},
            headerAttributes: {style: 'text-align:center;'}
        },
        {
            field: 'extra_file_count',
            width: 110,
            title: '附件数量',
            template: function (item) {
                return item.extra_file_count ? parseFloat(item.extra_file_count).toFixed(0) : ''
            },
            footerTemplate: '#=kendo.format("{0:n0}",sum)#',
            format: "{0:n1}",
            attributes: {'class': 'kendo-custum-number'},
            headerAttributes: {style: 'text-align:center;'},
            footerAttributes: {style: "text-align:right;"}
        },
    ];
    let grid = $("#page_recycle_emp_grid").kendoGrid({
        sortable: true,
        resizable: true,
        allowCopy: true,
        selectable: "multiple row",
        editable: false,
        filterable: true,
        title: "报表",
        pageable: {
            pageSize: 200
        },
        dataSource: dataSource,
        excel: {
            fileName: "员工档案.xlsx",
            proxyURL: "",
            allPages: true,
            filterable: true
        },
        columnMenu: {
            sortable: true
        },
        height: '99%',
        reorderable: true,
        dataBound: function () {
            let rows = this.items();
            $(rows).each(function () {
                let index = $(this).index() + 1;
                let rowLabel = $(this).find(".row-number");
                $(rowLabel).html(index);
            });
        },
        columnResize: function (e) {
            let field = e.column.field;
            let newWidth = e.newWidth;
            let oldWidth = e.oldWidth;
            if (newWidth < 20) {
                $(this).hideColumn(field);
            } else {
                $.post("userDeploy/update/single", {
                    menuId: menuId,
                    field: field + SUFFIX,
                    width: newWidth
                }, function (data) {
                    if (data.success) {
                    }
                }, "json");
            }
        },
        columnHide: function (e) {  //列隐藏事件
            let field = e.column.field;
            $.post("userDeploy/update/single", {menuId: menuId, field: field + SUFFIX, hidden: true}, function (data) {
            }, "json");
        },
        columnShow: function (e) {  //列显示事件
            let field = e.column.field;
            $.post("userDeploy/update/single", {menuId: menuId, field: field + SUFFIX, hidden: false}, function (data) {
            }, "json");
        },
        columnReorder: function (e) {
            let newColumns = JSON.parse(JSON.stringify(e.sender.columns))
            newColumns = reorder(newColumns, e.oldIndex, e.newIndex)
            let col = []
            for (let i = 0; i < newColumns.length; i++) {
                if (newColumns[i]['field'])
                    col.push({
                        serialNo: i,
                        menuId: menuId,
                        field: newColumns[i]['field'] + SUFFIX
                    });
            }
            $.ajax({
                url: 'userDeploy/update/batch',
                contentType: 'application/json',
                data: JSON.stringify(col),
                type: 'post',
                dataType: 'json',
                success: function (data) {
                }
            })
        },
    });
    //  绑定双击事件
    grid.on('dblclick', 'tr', function (e) {
        /*       let kGrid = $('#page_recycle_emp_grid').data('kendoGrid');
               let selectItem = kGrid.dataItem(e.currentTarget);
               if (selectItem) {
                   $('#page_emp_editable_dialog').dialog('open');
                   $.ajax({
                       url: 'employee/queryByPk/' + selectItem.id,
                       type: 'GET',
                       dataType: 'json',
                       success: function (data) {
                           if (data) {
                               $('#page_emp_editor_form').form('load', data);
                               $.disableFormElement($('#page_emp_editor_form'));
                               $('#page_emp_editor_file_grid').edatagrid('disableEditing');
                               $('#page_emp_editor_file_grid').datagrid('loadData', {
                                   total: data.detail.length,
                                   rows: data.detail
                               });
                           }
                       }
                   })
               }*/
    })
    let k = $('#page_recycle_emp_grid').data('kendoGrid');
    let columnNames = [];
    columns.forEach(item => {
        let arr = {};
        if (item['field']) {
            arr.field = item['field'] + SUFFIX;
            arr.hidden = item['hidden'] ? true : false;
            arr.width = item['width'] ? item['width'] : null;
            arr.menuId = menuId;
            columnNames.push(arr);
        }
    })
    loadOptions(k, columnNames, columns, SUFFIX);
}

// 员工恢复按钮
function btn_page_recycle_bin_emp_recovery() {
    let selectItems = getSelectItems($('#page_recycle_emp_grid'));
    if (!selectItems || selectItems.length <= 0) {
        $.messager.alert('提示', '未选中!', 'warning');
        return;
    }

    let item = [];
    for (let i = 0; i < selectItems.length; i++) {
        item.push({id: selectItems[i].id, docStatus: 1})
    }
    $.messager.confirm('提示', '是否恢复?', function (r) {
        if (r) {
            $.ajax({
                url: 'employee/multiUpdate',
                type: 'POST',
                dataType: 'json',
                data: JSON.stringify(item),
                contentType: 'application/json',
                success: function (data) {
                    if (data.success) {
                        $('#page_recycle_emp_grid').data('kendoGrid').dataSource.read();
                    }
                    $.messager.show({title: data.state, msg: data.message});
                }
            })

        }
    })
}

//  文档恢复按钮
function btn_page_recycle_bin_doc_recovery() {
    let selectItems = getSelectItems($('#page_recycle_doc_grid'));
    if (!selectItems || selectItems.length <= 0) {
        $.messager.alert('提示', '未选中!', 'warning');
        return;
    }
    let item = [];
    for (let i = 0; i < selectItems.length; i++) {
        item.push({id: selectItems[i].id, docStatus: 1})
    }
    $.messager.confirm('提示', '是否恢复?', function (r) {
        if (r) {
            $.ajax({
                url: 'document/multiUpdate',
                type: 'POST',
                dataType: 'json',
                data: JSON.stringify(item),
                contentType: 'application/json',
                success: function (data) {
                    if (data.success) {
                        $('#page_recycle_doc_grid').data('kendoGrid').dataSource.read();
                    }
                    $.messager.show({title: data.state, msg: data.message});
                }
            })
        }
    });
}

//  文档清空按钮
function btn_page_recycle_bin_doc_clear() {
    let selectItems = getSelectItems($('#page_recycle_doc_grid'));
    if (!selectItems || selectItems.length <= 0) {
        $.messager.alert('提示', '未选中!', 'warning');
        return;
    }
    let item = [];
    for (let i = 0; i < selectItems.length; i++) {
        item.push({id: selectItems[i].id, docStatus: 2})
    }
    $.messager.confirm('提示', '是否清空?', function (r) {
        if (r) {
            $.ajax({
                url: 'document/multiUpdate',
                type: 'POST',
                dataType: 'json',
                data: JSON.stringify(item),
                contentType: 'application/json',
                success: function (data) {
                    if (data.success) {
                        $('#page_recycle_doc_grid').data('kendoGrid').dataSource.read();
                    }
                    $.messager.show({title: data.state, msg: data.message});
                }
            })
        }
    })
}

//  员工清空按钮
function btn_page_recycle_bin_emp_clear() {
    let selectItems = getSelectItems($('#page_recycle_emp_grid'));
    if (!selectItems || selectItems.length <= 0) {
        $.messager.alert('提示', '未选中!', 'warning');
        return;
    }
    let item = [];
    for (let i = 0; i < selectItems.length; i++) {
        item.push({id: selectItems[i].id, docStatus: 2})
    }
    $.messager.confirm('提示', '是否清空?', function (r) {
        if (r) {
            $.ajax({
                url: 'employee/multiUpdate',
                type: 'POST',
                dataType: 'json',
                data: JSON.stringify(item),
                contentType: 'application/json',
                success: function (data) {
                    if (data.success) {
                        $('#page_recycle_emp_grid').data('kendoGrid').dataSource.read();
                    }
                    $.messager.show({title: data.state, msg: data.message});
                }
            })
        }
    });
}